
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.ticker import FuncFormatter
import sys 
nx=int(sys.argv[1])
ny=int(sys.argv[2])
nz=int(sys.argv[3])
subx=int(nx/int(sys.argv[4]))
suby=int(ny/int(sys.argv[5]))
snap1=np.zeros((nx,ny,nz),dtype='float32')
for i in range(int(sys.argv[4])):
  for j in range(int(sys.argv[5])):
    print("./snap/snap%d-%d.dat"%(j,i))
    f=open("./snap/snap%d-%d.dat"%(j,i))
    snap=np.fromfile(f,dtype='float32');
    snap1[0+subx*i:subx+subx*i,0+suby*j:suby+suby*j,:]=snap.reshape(subx,suby,nz)
snap11=np.zeros((nx,ny,nz),dtype='float32')
aa=snap1[100,:,:].T
aa.tofile("./snap/snaprtm.dat")

"""
for i in range(2,nx-2):
    print(i)
    for j in range(2,ny-2):
        for k in range(2,nz-2):
           snap11[i,j,k]= snap1[i+1,j,k]+snap1[i-1,j,k]+snap11[i,j+1,k]+snap1[i,j-1,k]+snap1[i,j,k+1]+snap1[i,j,k-1]+snap1[i,j,k+1]
           -6*snap1[i,j,k];
"""

##plt.imshow(np.dstack((a,b)))
#ax=plt.gca()
#plt.subplot(131)
#plt.imshow(snap1[100,:,:].T)
##plt.imshow(snap1[100,30:-30,50:-30].T)
#plt.colorbar()
#plt.xlabel("yyy")
#plt.ylabel("zzz")
##plt.imshow(snap1[64,:,:].T)

#plt.subplot(132)
#plt.imshow(snap1[:,100,:].T)
plt.imshow(snap1[30:-30,100,50:-30].T)
plt.colorbar()
plt.xlabel("xxx")
plt.ylabel("zzz")

#plt.subplot(133)
#plt.imshow(snap1[:,:,100].T)
#plt.imshow(snap1[30:-30,30:-30,40].T)
#ax.invert_xaxis()
plt.show()
